﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace qly
{
    class Hoadon
    {
        HoadonDAL dal = new HoadonDAL();
        public Hoadon()
        {

        }
        public DataTable DanhSachHoaDon()
        {
            DataTable dt = dal.DocDanhSachHoaDon();
            return dt;
        }
        public void XoaHoaDon(string sohd)
        {
            dal.XoaHoaDon(sohd);
        }
        public void LuuHoaDon(string hoadon, string mahang, string diengiai, double soluong,
                              double dongia)
        {
            double trigia = soluong * dongia;
            double khuyenmai = 0.0;
            if (trigia > 20000000)
                khuyenmai = (trigia * 5) / 100;
            else
                khuyenmai = 0.0;
            dal.ThemHoaDon(hoadon, mahang, diengiai, soluong, dongia, trigia, khuyenmai);
        }
        public void SuaHoaDon(string hoadon, string mahang, string diengiai, double soluong,
                             double dongia)
        {
            double trigia = soluong * dongia;
            double khuyenmai = 0.0;
            if (trigia > 20000000)
                khuyenmai = (trigia * 5) / 100;
            else
                khuyenmai = 0.0;
            dal.SuaHoaDon(hoadon, mahang, diengiai, soluong, dongia, trigia, khuyenmai);
        }
    }
}
